package com.dxk.dao;

import com.dxk.pojo.Department;

import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;

import java.util.Map;

@Repository
public class DepartmentDao {

    //模拟数据库，类加载是就产生数据

    private static Map<Integer,Department>  department=null;
    static {

            department=new HashMap<Integer,Department>();
            department.put(1001,new Department(1001,"教学部"));
            department.put(1002,new Department(1001,"教研部"));
            department.put(1003,new Department(1002,"教育部"));
            department.put(1004,new Department(1003,"信息部"));
            department.put(1005,new Department(1004,"后期部"));
    }


    //获取所有部门
    public Collection<Department> getAllDepartment(){

        return department.values();

    }
    //根据id获取部门
    public Department getDepartmentById(Integer id){

        if(id!=null){
            return department.get(id);
        }
        return null;
    }








}
